import React, { Component } from 'react';
import { formatDate } from '@/assets/js/methods'
import { Calendar } from 'antd-mobile';
import "../order/OrderProgress.scss"
import "./Performance.scss"
const data = [
	{ num: '001', name: '鞠志锋', order: 1, money: '1800.00', ticheng: 100 },
	{ num: '002', name: '鞠志锋', order: 1, money: '1800.00', ticheng: 100 },
]
const now = new Date();
class Performance extends Component {
	originbodyScrollY = document.getElementsByTagName('body')[0].style.overflowY;
	constructor() {
		super()
		this.state = {
			type: true,
			show: false,
			config: {
				type: 'one'
			},
		}
	}
	onSelectHasDisableDate = (dates) => {
		console.warn('onSelectHasDisableDate', dates);
	}

	onConfirm = (startTime) => {
		console.log(startTime.getTime())
		document.getElementsByTagName('body')[0].style.overflowY = this.originbodyScrollY;
		this.setState({
			show: false,
			startTime: formatDate(startTime.getTime())
		});
	}

	onCancel = () => {
		document.getElementsByTagName('body')[0].style.overflowY = this.originbodyScrollY;
		this.setState({
			show: false,
			startTime: undefined,
			endTime: undefined,
		});
	}
	componentDidMount() {
		document.getElementsByTagName('title')[0].innerHTML = '销售业绩'
		this.setState({
			startTime: formatDate(new Date().getTime())
		})
	}
	render() {
		let height = window.screen.height
		return (
			<div className="other-page OrderProgress performance" style={{ minHeight: height + 'px' }}>
				<div className="topbar flex y-center space-between">
					<span className="flex y-center">
						<span>类型：{this.state.type ? '销售员业绩' : '安装工业绩'}</span>
						<img
							src={require('../../images/switch.png')}
							alt=""
							className="ml10"
							onClick={() => {
								this.setState({
									type: !this.state.type
								})
							}} />
					</span>
					<span className="flex y-center">
						<span>{this.state.startTime}</span>
						<img src={require('../../images/calendar.png')}
							alt=""
							className="ml20"
							onClick={() => {
								document.getElementsByTagName('body')[0].style.overflowY = 'hidden';
								this.setState({
									show: true
								});
							}} />
					</span>
				</div>
				<div className='topcaption border-b'>
					<div>员工编号</div>
					<div>姓名</div>
					<div>完成订单</div>
					<div>{this.state.type ? '金额' : '好评'}</div>
					<div>提成</div>
				</div>
				<div className='content'>
					{
						data.map((item, index) => {
							return (
								<div
									className='item border-b'
									key={index}
									style={{ borderBottomWidth: index === data.length - 1 ? 0 : 1 }} >
									<div>{item.num}</div>
									<div>{item.name}</div>
									<div>{item.order}</div>
									<div>{item.money}</div>
									<div>{item.ticheng}</div>
								</div>
							)
						})
					}
				</div>
				<div className="big-color-but">结算业绩</div>

				<Calendar
					{...this.state.config}
					visible={this.state.show}
					onCancel={this.onCancel}
					onConfirm={this.onConfirm}
					onSelectHasDisableDate={this.onSelectHasDisableDate}
					getDateExtra={this.getDateExtra}
					defaultDate={now}
					minDate={new Date(+now - 5184000000)}
					maxDate={new Date(+now + 31536000000)}
				/>
			</div>
		);
	}
}

export default Performance;